//
//  LTM_PopAlertBaseView.m
//  LTM_Inherit_PopView_Objc
//
//  Created by 柯南 on 2021/11/25.
//

#import "LTM_PopAlertBaseView.h"
#import <Masonry/Masonry.h>

@interface LTM_PopAlertBaseView ()
/// 弹框父视图
@property (nonatomic, strong) UIView *bgView;
/// 顶部图标
@property (nonatomic, strong) UIImageView *topImageView;
/// 弹框内容父视图
@property (nonatomic, strong, readwrite) UIView *popBgView;

@end

@implementation LTM_PopAlertBaseView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    
    if (self) {
        [self addSubview:self.bgView];
        [self.bgView addSubview:self.popBgView];
        [self.bgView addSubview:self.topImageView];
        [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self);
        }];
        [self.popBgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.bgView);
            make.left.right.bottom.equalTo(self.bgView);
        }];
        [self.topImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.bgView);
            make.centerX.equalTo(self.bgView);
            make.centerY.equalTo(self.popBgView.mas_top);
        }];
    }
    return self;
}
//MARK: Set
- (void)setTopImage:(UIImage *)topImage{
    _topImage = topImage;
    self.topImageView.image = _topImage;
}

#pragma mark - UILazy
- (UIView *)bgView{
    if (!_bgView) {
        _bgView = [[UIView alloc] init];
    }
    
    return _bgView;
}

- (UIImageView *)topImageView{
    if (!_topImageView) {
        _topImageView = [[UIImageView alloc] init];
    }
    
    return _topImageView;
}

- (UIView *)popBgView{
    if (!_popBgView) {
        _popBgView = [[UIView alloc] init];
        _popBgView.layer.cornerRadius = 15;
        _popBgView.layer.masksToBounds = true;
    }
    
    return _popBgView;
}


@end
